package com.wbhz.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wbhz.entity.BankCard;
import com.wbhz.entity.Message;
import com.wbhz.entity.User;
import com.wbhz.entity.Vip;
import com.wbhz.mapper.UserMapper;
import com.wbhz.service.UserService;
@Service
public class UserServiceImpl implements UserService {
	Logger logger = Logger.getLogger(UserServiceImpl.class);
	
	@Autowired
	private UserMapper userMapper;
	
	public int insertUser(User user) {
		logger.info("UserServiceImpl类,insertUser的方法");
		return userMapper.insertUser(user);
	}

	public User selectUserByEmail(User user) {
		logger.info("UserServiceImpl类,selectUserByEmail的方法");
		return userMapper.selectUserByEmail(user);
	}

	public User selectUserByEmailAndPwd(User user) {
		logger.info("UserServiceImpl类,selectUserByEmailAndPwd的方法");
		return userMapper.selectUserByEmailAndPwd(user);
	}

	public int updateUserDetail(User user) {
		logger.info("UserServiceImpl类, selectUserByEmailAndPwd方法");
		return userMapper.updateUserDetail(user);
	}

	public int updatePwd(String userPwd, String userEmail) {
		logger.info("UserServiceImpl类, updatePwd方法");
		return userMapper.updatePwd(userPwd, userEmail);
	}

	public int updateMoney(int userId, int postReward) {
		logger.info("UserServiceImpl类, updateMoney方法");
		return userMapper.updateMoney(userId, postReward);
	}

	@Override
	public List<User> selectUserIdAndName() {
		logger.info("UserServiceImpl类, selectUserIdAndName方法");
		return userMapper.selectUserIdAndName();
	}

	@Override
	public List<User> selectUserByReply(int postId) {
		logger.info("UserServiceImpl类, selectUserByReply方法");
		return userMapper.selectUserByReply(postId);
	}

	public int insertBankCard(String userName, String random) {
		logger.info("UserServiceImpl类, insertBankCard方法");
		return userMapper.insertBankCard(userName, random);
	}

	public List<Message> selectUserMsg(int userId) {
		logger.info("UserServiceImpl类, selectUserMsg方法");
		return userMapper.selectUserMsg(userId);
	}

	public Message selectMsgDetail(int msgId) {
		logger.info("UserServiceImpl类, selectMsgDetail方法");
		return userMapper.selectMsgDetail(msgId);
	}

	public int insertRight(User user) {
		logger.info("UserServiceImpl类, insertRight方法");
		return userMapper.insertRight(user);
	}

	public int selectUIdByUName(String byReplyName) {
		logger.info("UserServiceImpl类, selectUIdByUName方法");
		return userMapper.selectUIdByUName(byReplyName);
	}

	public List<User> selectReplyUList(int postId) {
		logger.info("UserServiceImpl类, selectReplyUList方法");
		return userMapper.selectReplyUList(postId);
	}
	// 银行卡 ByUId
	public BankCard selectBankCard(int userId) {
		logger.info("UserServiceImpl类, selectBankCard方法");
		return userMapper.selectBankCard(userId);
	}

	public Integer selectB_CByNumAndPwd(String bankcardNumber, String bankcardPwd) {
		logger.info("UserServiceImpl类, selectB_CByNumAndPwd方法");
		return userMapper.selectBanselectB_CByNumAndPwdkCard(bankcardNumber,  bankcardPwd);
	}

	public void subB_Cbalance(String bankcardNumber, int balance) {
		logger.info("UserServiceImpl类, subB_Cbalance方法");
		userMapper.subB_Cbalance(bankcardNumber, balance);
	}

	public int selectURight(int userId) {
		logger.info("UserServiceImpl类, selectURight方法");
		return userMapper.selectURight(userId);
	}

	public void subB_CBalance2(int balance, int userId) {
		logger.info("UserServiceImpl类, subB_CBalance方法");
		userMapper.subB_CBalance2(balance, userId);
	}

	public void subUMoney(int userId, int balance) {
		logger.info("UserServiceImpl类, subUMoney方法");
		userMapper.subUMoney(userId, balance);
	}

	public Integer isEnougMoney(int userId, int balance) {
		logger.info("UserServiceImpl类, isEnougMoney方法");
		return userMapper.isEnougMoney(userId, balance);
	}

	public Integer isEnougBalance(int userId, int balance) {
		logger.info("UserServiceImpl类, isEnougBalance方法");
		return userMapper.isEnougBalance(userId, balance);
	}

	public int updateURight(int userId) {
		logger.info("UserServiceImpl类, updateURight方法");
		return userMapper.updateURight(userId);
	}

	public int insertVipMonth(int userId, int months) {
		logger.info("UserServiceImpl类, insertVipMonth方法");
		if (months == 1) {
			return userMapper.insertVip1Month(userId);
		}else if (months == 3) {
			return userMapper.insertVip3Month(userId);
		}else if (months == 6) {
			return userMapper.insertVip6Month(userId);
		}else {
			return userMapper.insertVip12Month(userId);
		}
	}

	public Vip selectVipDetail(int userId) {
		logger.info("UserServiceImpl类, selectVipDetail方法");
		return userMapper.selectVipDetail(userId);
	}
	
}
